-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2283 - Chat should not replace symbols in <code> #2293
Conversation
Test summaryRun details
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud |
const strSplitByCodeMarkdown = splitStringByMarkdownCode(str) | ||
strSplitByCodeMarkdown.forEach((entry, index) => { | ||
if (entry.type === 'plain' && strSplitByCodeMarkdown[index - 1]?.text !== '```') { | ||
let entryText = entry.text | ||
entryText = entryText.replace(/</g, '<').replace(/>/g, '>') | ||
|
||
str = str.replace(/\n(?=\n)/g, '\n<br>') | ||
.replace(/<br>\n(\s*)(\d+\.|-|```)/g, '\n\n$1$2') // custom-handling the case where <br> is directly followed by the start of block-code (```) | ||
.replace(/(\d+\.|-)(\s.+)\n<br>/g, '$1$2\n\n') // this is a custom-logic added so that the end of ordered/un-ordered lists are correctly detected by markedjs. | ||
entryText = entryText.replace(/\n(?=\n)/g, '\n<br>') | ||
.replace(/<br>\n(\s*)(\d+\.|-)/g, '\n\n$1$2') // custom-handling the case where <br> is directly followed by the start of ordered/unordered lists | ||
.replace(/(\d+\.|-)(\s.+)\n<br>/g, '$1$2\n\n') // this is a custom-logic added so that the end of ordered/un-ordered lists are correctly detected by markedjs. | ||
|
||
entry.text = entryText | ||
} | ||
}) | ||
|
||
str = combineMarkdownSegmentListIntoString(strSplitByCodeMarkdown) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cause of the issue was that,
These additional fixes & adjustments related to white-spaces, line-breaks and <
and >
did not need to be applied to the contents of <code>...</code>
.
So a logic added here where it selectively apply these adjustments to the text contents outside of <code>...</code>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic!
closes #2283
[Proof of the fix]